﻿using Computer_Manager.DAL;
using Computer_Manager.DTO;
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Computer_Manager.BUS
{
    class BUS_company
    {
        DAL_company dal = new DAL_company();

        public bool company_insert(DTO_company obj)
        {
            try
            {
                dal.company_insert(obj);
            }
            catch (Exception e)
            {

                XtraMessageBox.Show(e.Message, "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            return true;

        }

        public bool company_Update(DTO_company obj)
        {
            try
            {
                dal.company_Update(obj);
            }
            catch (Exception e)
            {

                XtraMessageBox.Show(e.Message, "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            return true;
        }
        
        public bool company_Delete(DTO_company obj)
        {
            try
            {
                dal.company_Delete(obj);
            }
            catch (Exception e)
            {

                XtraMessageBox.Show(e.Message, "Xóa không công", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            return true;
        }

        public DataTable GetByID(DTO_company obj)
        {
            DataTable dt = new DataTable();
            try
            {
                dt = dal.GetByID(obj);
            }
            catch (Exception)
            {

                throw;
            }
            return dt;
        }
        

        public DataTable GetAll()
        {
            DataTable dt = new DataTable();
            try
            {
                dt = dal.GetAll();

            }
            catch (Exception e)
            {

                XtraMessageBox.Show(e.Message, "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return dt;
        }
    }
}
